package com.skyolder.milkbee.repository;

import com.skyolder.milkbee.domain.Advertisement;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;

import java.util.List;

/**
 * Spring Data JPA repository for the Advertisement entity.
 */
@SuppressWarnings("unused")
public interface AdvertisementRepository extends JpaRepository<Advertisement,Long> {

	@Query("from Advertisement a where a.categoryId in(?1,0) and a.startAt<now() and endAt>now()")
	Page<Advertisement> queryByCategory(Long categoryId, Pageable pageable);

	@Query("from Advertisement a where  a.startAt>now()")
	Page<Advertisement> queryByPrematurity(Pageable pageable);
	@Query("from Advertisement a where  a.startAt<=now() and a.endAt>now()")
	Page<Advertisement> queryByOnline(Pageable pageable);
	@Query("from Advertisement a where  a.endAt<now()")
	Page<Advertisement> queryByExpire(Pageable pageable);

}
